package com.shop.front.dao.store;

import com.shop.jpa.BaseDao;
import com.shop.domain.store.StoreProduct;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface StoreProductDao extends BaseDao<StoreProduct, Long> {


    @Modifying(clearAutomatically = true)
    @Query("update StoreProduct set sales = sales + ?2 where id = ?1")
    int addSales(Long id, int num);

    @Modifying(clearAutomatically = true)
    @Query("update StoreProduct set snapStock = snapStock - ?2 where id = ?1")
    int subSnapStock(Long id, int num);

}
